#e
#Title[zNu20mVgv]
#Text[ʁBB
Ƃ܂ŁB]
#ScriptVersion[2]

script_enemy_main
{
	let scroll=0;
	let flag=0;
	let angle=0;
	let move=0;
	let cx=GetCenterX();
	let cy=GetCenterY();
	let boss=GetCurrentScriptDirectory~"img\boss7-2.png";
	let eye=GetCurrentScriptDirectory~"img\bg7-1.png";
	let asa=GetCurrentScriptDirectory~"img\bg7-2.png";
	LoadUserShotData(GetCurrentScriptDirectory~"shot.txt");
	@Initialize
	{
		SetScore(30000);
		SetLife(100);
		SetDamageRate(10,0);
		SetMovePosition02(cx,cy-120,60);
		SetTimer(80);
		SetInvincibility(240);
		LoadGraphic(boss);
		LoadGraphic(eye);
		LoadGraphic(asa);
		shottask;
		movetask;
		drawtask;
		bombtask;
		CutIn(YOUMU,"zNu20mVgv",0,0,0,0,0);
	}
	@MainLoop
	{
		yield;
	}
	@Finalize
	{
		loop(16)
		{
			CreateItem(ITEM_SCORE,GetX+rand(-30,30),GetY+rand(-30,30));
		}
		DeleteGraphic(boss);
		DeleteGraphic(eye);
		DeleteGraphic(asa);
	}
	@DrawLoop
	{
		SetTexture(boss);	
		if(flag==1)
		{
			SetGraphicRect(52,0,81,63);
		}
		else if(flag==2)
		{
			SetGraphicRect(24,0,52,63);
		}
		else
		{
			SetGraphicRect(0,0,24,63);
		}
		SetGraphicScale(1,1);
		SetGraphicAngle(0,0,angle);
		DrawGraphic(GetX,GetY);
	}
	@BackGround
	{
		SetColor(128,128,128);
		SetTexture(eye);	
		SetGraphicRect(0,0,384,448);
		SetAlpha(255);
		SetGraphicScale(1,1);
		SetGraphicAngle(0,0,0);
		DrawGraphic(cx,cy);
		SetColor(255,255,255);
		SetTexture(asa);	
		SetGraphicRect(0,0,888,189*5);
		SetAlpha(64);
		SetGraphicScale(0.5,0.75);
		SetGraphicAngle(0,0,0);
		DrawGraphic(cx+scroll,cy);
		DrawGraphic(cx+scroll-444,cy);
		if(scroll>444)
		{
			scroll=0;
		}
	}
	task shottask
	{
		let speed=0;
		let angle=0;
		wait(120);
		loop
		{
			wait(3);
			if(move==1)
			{
				CreateShot01(GetX,GetY,0.3,GetAngleToPlayer+angle,21,5);
				CreateShot01(GetX,GetY,0.3,GetAngleToPlayer+angle+180,21,5);
				angle+=17;
			}
		}
	}
	task movetask
	{
		let angleset=0;
		wait(120);
		loop
		{
			move=1;
			let w=30;
			let y=0;
			loop(4)
			{
				SetMovePosition02(GetClipMinX,GetClipMinY+y,w);
				wait(w);
				y+=60;
				SetMovePosition02(GetClipMaxX,GetClipMinY+y,w+5);
				wait(w+5);
				w+=5;
				y+=60;
			}
			wait(30);
			loop(4)
			{
				y-=60;
				SetMovePosition02(GetClipMinX,GetClipMinY+y,w);
				wait(w);
				y-=60;
				SetMovePosition02(GetClipMaxX,GetClipMinY+y,w+5);
				wait(w+5);
				w+=5;
			}
			move=0;
			SetMovePosition02(cx,cy-120,60);
			wait(240);
		}
	}
	task drawtask
	{
		let x=0;
		loop
		{	
			if(GetX>x+0.5)
			{
				flag=1;
			}
			else if(GetX<x-0.5)
			{
				flag=2;
			}
			else
			{
				flag=0;
			}
			x=GetX;
			scroll++;
			yield;
		}
	}
	task bombtask
	{
		loop
		{
			if(OnBomb)
			{
				SetAlpha(64);
				SetDamageRate(0,0);
			}
			else
			{
				SetAlpha(255);
				SetDamageRate(10,0);
				SetCollisionA(GetX(),GetY(),24);
				SetCollisionB(GetX(),GetY(),24);
			}
			if(move==1)
			{
				SetAlpha(255);
				SetDamageRate(0,0);
				SetCollisionA(GetX(),GetY(),24);
				SetCollisionB(GetX(),GetY(),24);
			}
			yield;
		}
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}